<?php

/**
 * Indicateur filter form base class.
 *
 * @package    KC-INDICATEURS
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseIndicateurFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'type_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Type'), 'add_empty' => true)),
      'libelle'       => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'libelle_court' => new sfWidgetFormFilterInput(),
      'commentaire'   => new sfWidgetFormFilterInput(),
      'seuil_alerte'  => new sfWidgetFormFilterInput(),
      'seuil_erreur'  => new sfWidgetFormFilterInput(),
      'visuel'        => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'historique'    => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'from_mantis'   => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
    ));

    $this->setValidators(array(
      'type_id'       => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Type'), 'column' => 'id')),
      'libelle'       => new sfValidatorPass(array('required' => false)),
      'libelle_court' => new sfValidatorPass(array('required' => false)),
      'commentaire'   => new sfValidatorPass(array('required' => false)),
      'seuil_alerte'  => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'seuil_erreur'  => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'visuel'        => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'historique'    => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'from_mantis'   => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
    ));

    $this->widgetSchema->setNameFormat('indicateur_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Indicateur';
  }

  public function getFields()
  {
    return array(
      'id'            => 'Number',
      'type_id'       => 'ForeignKey',
      'libelle'       => 'Text',
      'libelle_court' => 'Text',
      'commentaire'   => 'Text',
      'seuil_alerte'  => 'Number',
      'seuil_erreur'  => 'Number',
      'visuel'        => 'Boolean',
      'historique'    => 'Boolean',
      'from_mantis'   => 'Boolean',
    );
  }
}
